<template>
    <div>
        <base-list ref="jobMachinery" :condition="condition" :datas.sync="jobMachinery" :pageSearch="pageSearch">
            <el-form :inline="true" :model="condition" class="search-form" slot="search" label-width="80px">
                <el-row>
                    <el-col :span="7" class="search-width4">
                        <el-form-item label="仓库代码">
                            <!--<el-input v-model="condition['search_LIKE_resourceName']"></el-input>-->
                            <auto-search-resource searchType="JOB_JX" searchName="resourceName" @selectName="v=>condition['search_LIKE_resourceName']=v"></auto-search-resource>
                        </el-form-item>
                    </el-col>
                    <el-col :span="7" class="search-width4">
                        <el-form-item label="仓库名称">
                            <!--<el-input v-model="condition['search_LIKE_resourceName']"></el-input>-->
                            <auto-search-resource searchType="JOB_JX" searchName="resourceName" @selectName="v=>condition['search_LIKE_resourceName']=v"></auto-search-resource>
                        </el-form-item>
                    </el-col>
                    <el-col :span="7" class="search-width4">
                        <el-form-item label="所属单位">
                            <!--<el-input v-model="condition['search_LIKE_resourceName']"></el-input>-->
                            <auto-search-resource searchType="JOB_JX" searchName="resourceName" @selectName="v=>condition['search_LIKE_resourceName']=v"></auto-search-resource>
                        </el-form-item>
                    </el-col>
                    <el-col :span="2">
                        <el-button type="primary" icon="el-icon-search" @click="loadData" class="ml-80">查 询</el-button>
                        <!-- <el-button formVisible="true" icon="el-icon-plus" @click="handleDialogFormOpen(false)" v-if="power('WJOB_BASEMGR_MACHINE:ADD')">
                            新增
                        </el-button> -->
                    </el-col>
                </el-row>
            </el-form>
            <el-table slot="list" :data="jobMachinery" border stripe max-height="500">
                <el-table-column prop="number" label="序号"  min-width="130"></el-table-column>
                <el-table-column prop="resourceName" label="仓库代码"  min-width="130"></el-table-column>
                <el-table-column prop="typeName" label="仓库名称"  min-width="130"></el-table-column>
                <el-table-column prop="categoryName" label="仓库类型"  min-width="120"></el-table-column>
                <el-table-column prop="terminalName" label="联系电话"  min-width="120"></el-table-column>
                <el-table-column prop="orgName" label="联系人"  min-width="200"></el-table-column>
                <el-table-column prop="deptName" label="所属单位"  min-width="200"></el-table-column>
                <el-table-column prop="deptName" label="所在地"  min-width="200"></el-table-column>
                <el-table-column prop="resourceDescribe" label="备注"  min-width="200"></el-table-column>
                <el-table-column fixed="right" align="center" label="操作"  width="140">
                    <template slot-scope="scope">
                        <el-button size="small" type="text" @click="handleDialogFormOpen(true,scope.row)" v-if="power('WJOB_BASEMGR_MACHINE:UPD')">
                            编辑
                        </el-button>
                        <el-button type="text" class="danger" size="small" @click="handleRemove(scope.row)" v-if="power('WJOB_BASEMGR_MACHINE:DEL')">删除
                        </el-button>
                    </template>
                </el-table-column>
            </el-table>
        </base-list>
        <!-- <job-machinery-form ref="jobMachineryForm" @load="loadData"></job-machinery-form> -->
    </div>
</template>

<script>
    import { deleteJobMachinery, getJobMachineryList } from "@/api/baseResource/baseResource";
    import autoSearchOrg from '@/components/autocomplete/autoSearchOrg'
    import autoSearchDic from '@/components/autocomplete/autoSearchDic'
    import autoSearchResource from '@/components/autocomplete/autoSearchResource'
    // import jobMachineryForm from './jobMachineryForm'

    export default {
        name: "管辖仓库设置",
        components: {
            // jobMachineryForm,
            autoSearchOrg,
            autoSearchDic,
            autoSearchResource
        },
        data() {
            return {
                condition: {}, // 查询条件
                jobMachinery: [], // table数组
                pageSearch: getJobMachineryList, // 分页查询api接口
                id: ''
            }
        },
        mounted() {
            this.$nextTick(() => {
                this.loadData()
            })
        },
        methods: {
            loadData() {
                this.$refs.jobMachinery.loadData()
            },
            handleDialogFormOpen(bool, item) {
                if (bool) {
                    let form = JSON.parse(JSON.stringify(item))
                    this.$refs.jobMachineryForm.form = {
                        id:form.id,
                        resourceName:form.resourceName,
                        typeId:form.typeId,
                        typeName:form.typeName,
                        typeCode:form.typeCode,
                        categoryId:form.categoryId,
                        categoryName:form.categoryName,
                        categoryCode:form.categoryCode,
                        orgId:form.orgId,
                        orgName:form.orgName,
                        deptId:form.deptId,
                        deptName:form.deptName,
                        terminalId:form.terminalId,
                        terminalName:form.terminalName,
                        valid:form.valid,
                        wharf:form.wharf,
                        yard:form.yard,
                        warehouse:form.warehouse,
                        others:form.others,
                        resourceDescribe:form.resourceDescribe,
                    }
                    this.$refs.jobMachineryForm.isEdit = true
                    this.$refs.jobMachineryForm.dialogForm = true
                } else {
                    this.$refs.jobMachineryForm.dialogForm = true
                }
            },
            handleRemove(item) {
                this.$confirm(`是否删除该数据?`, '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    deleteJobMachinery(item.id).then(res => {
                        this.$message({
                            type: 'success',
                            message: `删除成功!`
                        });
                        this.loadData()
                    })
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消'
                    });
                });
            }
        },
    }

</script>

<style scoped>


</style>
